package com.java复习.练习一二四答案.demo5;

//三角形类
public class Triangle extends Ploygon{
    int base;
    int height;

    public Triangle(int base,int height){
        super(3);
        this.base = base;
        this.height = height;
        System.out.println("调用了子类的构造方法");
    }

    public int getArea(){
        return (base * height) / 2;
    }

    @Override
    public String toString() {
        return "三角形{" +
                "底为：" + base +
                ", 高为：" + height +
                '}';
    }
}
